﻿
using System;
using System.Web;
namespace Micua.Utility
{
    public static class MachineHelper
    {
        #region 返回与虚拟路径相对应的物理路径 +static string MapPath(string virtualPath)
        /// <summary>
        /// 返回与虚拟路径相对应的物理路径
        /// </summary>
        /// <remarks>
        ///  2014年01月09日 11:57 Created By iceStone
        /// </remarks>
        /// <param name="virtualPath">虚拟路径</param>
        /// <returns>物理路径</returns>
        public static string MapPath(string virtualPath)
        {
            var context = HttpContext.Current;
            if (context != null)
            {
                return context.Server.MapPath(virtualPath);
            }
            var root = AppDomain.CurrentDomain.BaseDirectory;
            return root + virtualPath.TrimStart('~', '/').Replace('/', '\\');
        }
        #endregion
    }
}
